
package org.apache.solr.handler.loader;

import java.io.*;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.update.processor.UpdateRequestProcessor;

public class CSVLoader extends ContentStreamLoader {

    @Override
    public void load(SolrQueryRequest req, SolrQueryResponse rsp, ContentStream stream, UpdateRequestProcessor processor) throws Exception {
        new SingleThreadedCSVLoader(req, processor).load(req, rsp, stream, processor);
    }
}

class SingleThreadedCSVLoader extends CSVLoaderBase {

    SingleThreadedCSVLoader(SolrQueryRequest req, UpdateRequestProcessor processor) {
        super(req, processor);
    }

    @Override
    void addDoc(int line, String[] vals) throws IOException {

        templateAdd.clear();
        SolrInputDocument doc = new SolrInputDocument();
        doAdd(line, vals, doc, templateAdd);
    }
}
